package com.example.arithmeticleetcode.leetcode.jan;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @program: arithmetic-leetcode
 * @description:
 * @author: FangZhen
 * @create: 2021-01-14 09:12
 **/
public class Demo11 {

    public static void main(String[] args) {
        int[] A = {1, 1, 0, 0, 0, 1, 0, 0, 1};
        int[] A1 = {0, 1, 1};
        prefixesDivBy52(A);
        prefixesDivBy52(A1);
    }

    public static List<Boolean> prefixesDivBy52(int[] A) {
        List<Boolean> ans = new ArrayList<>();

        int num = 0;
        for (int i = 0;i < A.length;i++) {
            num <<= 1;
            num += A[i];
            num %= 10;
            ans.add(num % 5 == 0);
        }

        return ans;
    }


    public static List<Boolean> prefixesDivBy5(int[] A) {
        List<Boolean> list = new ArrayList<>(A.length);
        int sum = A[0] == 1 ? 1 : 0;
        list.add(A[0] == 0);
        for (int i = 1; i < A.length; i++) {
            if (A[i] == 1) {
                sum += (1 << i);
            }
            list.add(sum % 5 == 0);

        }
        return list;
    }


    /**
     * 1598. 文件夹操作日志搜集器
     *
     * @param logs
     * @return
     */
    public int minOperations(String[] logs) {
        return 0;
    }


}
